/**
 * @file Prototypes.h
 * @brief Prototypes of functions internal to GDR
 * @author Matt Stallmann @date 28 Nov 2001
 * $Id: Prototypes.h 10 2007-06-28 20:08:57Z mfms $
 */

/*
 *  Copyright (C) 1989, 2001, 2007  Matthias Stallmann, Prashant Hebbar.
 *  Contact: matt_stallmann@ncsu.edu
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program (file COPYING.txt); if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 *  USA.
 */

/** functions in Main.c **/

extern void sig_handler(int); 
/**< what to do in case of Ctrl-C (suspend the animation) */

extern void show_help(int category, int message_index);
/**< displays a the indexed message at the top of the window (category
   indicates whether this is related to panel, menu, or other action) */

extern int p_menu(int xc, int yc);
/**< pops up the command menu in response to right mouse button;
   returns TRUE iff the QUIT command is selected */

extern void clear_graph_disp(void);
/**< erases the current graph */

extern void save_with_prompt(int x, int y);
/**< saves the graph in a file, prompting for file name and asking user if ok
   to overwrite existing file */

extern void load_with_prompt(int x, int y);
/**< reads a graph from a file, prompting for file name repeatedly until an
   existing file in correct format is found */

extern void menu_init(void);
/**< initializes the menu */

/** functions in Gdr.c **/

extern EJ_NODE * create_edge_record( vertex u, vertex v, char *label,
                                     int lx, int ly,
                                     int (*kn)[2], int display);
/**< creates an edge node with the given information: u and v are the
   endpoints, (lx,ly) is the location of the label window, the array kn
   gives the knot points, and display is the display info */

extern void clear_graph(vertex st_vx, vertex end_vx);
/**< erases the adacency list structure for vertices 'st_vx' through 'end_vx'
   and destroys the corresponding label windows for vertices and edges */

/** functions in Utilities.c **/

extern int near(int k, int x, int y);
/**< TRUE iff vertex k's circle contains point (x,y) */

extern int get_vx_id(int x, int y);
/**< return number of vertex containing point (x,y), if any, or NULL_VERTEX
   if none */

extern void HILITE(vertex id);
/**< highlight vertex 'id' on the screen */

extern void put_vx(vertex id);
/**< display vertex 'id' on the screen (highlight and/or expose label as
   appropriate) */

extern void ident(int id, int x, int y);
/**< write the vertex number 'id' on a vertex centered at (x,y); truncate to
   two digits if necessary */

extern void mov_elab_window(edge e, int x, int y);
/**< move label window for edge 'e' so that its lower left corner is at (x,y)
 */

extern void move_vx_ej(vertex id, int nu_x, int nu_y);
/**< move vertex 'id' to a new location, centered at (nu_x,nu_y); reposition
   edges and edge labels accordingly */

extern void put_edge(edge e);
/**< draw the edge 'e' on the window, making it highlighted and/or exposing
   its label if appropriate */

extern void erase_edge(edge e);
/**< erase the drawing of edge 'e' from the window */

extern void draw_edge(GC l_gc, edge edj);
/**< draw the edge 'edj' using graphics context 'l_gc' */

extern edge edge_from_window(Window lwin);
/**< returns the edge for which lwin is the label window (or NULL_VERTEX if
   none exists) */ 

extern vertex vertex_from_window(Window vwin);
/**< returns vertex for which vwin is the label window (or NULL_VERTEX if
   none exists) */ 

extern edge get_knot_at(int x, int y, int * a_indx);
/**< returns the edge with a knot at (x,y), if any (NULL_EDGE if none), and
   uses output argument a_indx to indicate which knot it is (0 or 1) */

extern void draw_arrow(int xh, int yh, double theta, int gx, int gy,
                       double length_factor);
/**< draw an arrow head at (xh,yh) pointing in direction theta; the
   coordinates gx and gy adjust for the length and angle of
   the edge (don't ask :) and length_factor can be adjusted to affect the
   overall arrow length */

extern void create_lab_win(Window p_win, struct ej_node *node_ptr);
/**< create a label window for the edge whose node is pointed to by
   'node_ptr'; the window 'p_win' is the parent window */

extern void redraw_edge_label(edge e);
/**< redraw the label for e (called when label changes or becomes exposed */

extern void create_vlab_win(Window p_win, vertex vx);
/**< create a label window for vertex 'vx'; the window 'p_win' is the parent
   window */

extern void redraw_vertex_label(vertex vx);
/**< redraw the label for vx (called when label changes or becomes exposed */

extern edge get_ej_at_xy(int xc, int yc);
/**< return an edge (if any) close to the position (xc,yc); return NULL_EDGE
   if none exists */

extern int check_on_edge(edge e, int x, int y);
/**< return TRUE iff the point (x,y) is close to edge 'e' */

extern int near_segment(int x, int y, int x1, int y1, int x2, int y2);
/**< returns TRUE if the point (x,y) is within EPS of the
   line segment from (x1,y1) to (x2,y2); uses Manhatten distance for all
   calculations so that integer arithmetic can be used throughout */

extern void clear_main_canvas(void);
/**< clears the main window (and the pixmap) */

extern void draw_gr(void);
/**< draws the whole graph from the adacency list structure (after clearing
   the window) */

extern void calc_adjust(int * xc1, int * yc1, int * xc2, int * yc2,
                        int * gx, int * gy);
/**< makes various calculations for adusting positions of knots and
   arrowheads when the endpoints of an edge are moved */

extern void t_affine(int x_fix, int y_fix, int x_old, int y_old, int x_new,
                     int y_new, int *ax, int *ay);
/**< generic tranformation routine for calculating relative positions */

extern double get_slope(int x1, int y1, int x2, int y2);
/**< returns slope of the line through (x1,y1) and (x2,y2) */

extern int handle_background_event(XEvent eve);
/**< handles events not caused by user intervention */

/** functions in List.c **/

extern H_NODE * new_list( void );
/**< returns a pointer to an empty list of edges */

extern edge add_to_list( EJ_NODE * edge_ptr, H_NODE * L );
/**< adds the edge record pointed to by edge_ptr to the list L;
   returns a pointer to the list node (to be used a an "edge") */

extern void remove_from_list( EJ_NODE * edge_ptr, H_NODE * L );
/**< removes the edge record pointed to by edge_ptr from the list L */

extern edge first_on_list( H_NODE * L );
/**< returns a pointer to the first node on list L (to be used as an "edge") */

extern edge next_on_list( edge e );
/**< the next edge after e on the "current" list */

extern EJ_NODE * get_edge_record( edge e );
/**< return a pointer to the edge record corresponding to node e */

/** functions in Panel.c **/

extern void pane_init(void);
/**< initializes the side panel */

extern void draw_panel_window(void);
/**< redraws the panel with the current selection highlighted */

extern void act_pane(int y);
/**< perform the action corresponding to y-coordinate 'y' (since panel is
   subdivided by horizontal lines, x-coordinate is not relevant) */

extern void get_2_knots(int (*kn)[2]);
/**< gets two knots from user via prompted mouse clicks and returns the 4
   coordinates via the 2 x 2 array 'kn' */

extern void init_knot(vertex vx1, vertex vx2, int (*kn)[2]);
/**< initializes the two knots for an edge between vertices 'vx1' and 'vx2';
   the positions of the knots are returned via the 2 x 2 array 'kn' */

extern void update_directed_in_panel(void);
/**< updates panel to reflect whether or not current graph is directed */

extern int is_panel_window(Window w);
/**< TRUE iff w is the panel window */

/** functions in Text.c (and not accessible to programmer) **/

/**<* functions in InOut.c **/

extern int read_in_gr( FILE * fd );
/**< read the graph from the file whose descriptor is fd; return 0 if no
   errors, 1 otherwise */

extern void print_graph_data( FILE * fd );
/**< print all information about the graph in the file pointed to by the
   descriptor fd */

/** end of Prototypes.h **/

/*  [Last modified: 2007 06 28 at 19:26:51 GMT] */
